package ch08_Swing高级组件.JInternalFrame;

import ch07_GUI编程.BaseFrame;

import javax.swing.*;

/**
 * @author 挚爱之夕
 * @date 2021/8/26 - 08 - 26 - 22:57
 * @Description: ch08.JInternalFrame
 * @Version: 1.0
 */
public class JInternalFrameDemo {
    void init(){
        BaseFrame f = new BaseFrame("JInternalFrame Demo");

        JInternalFrame[] iFrames = new JInternalFrame[4];//内部窗口数组
        JDesktopPane desktop = new JDesktopPane();//构造桌面面板以容纳内部窗口
        for (int i = 0; i < iFrames.length; i++) {
            iFrames[i] = new JInternalFrame("内部窗口"+(i+1));
            iFrames[i].setResizable(true);
            iFrames[i].setMaximizable(true);
            if(i%2==0){
                iFrames[i].setClosable(true);
                iFrames[i].setIconifiable(true);
            }
            iFrames[i].setSize(200,100);
            iFrames[i].setLocation(50-i*15,100-i*30);
            iFrames[i].setVisible(true);
            desktop.add(iFrames[i]);    //加入桌面面板
        }
        iFrames[1].toFront();//第二个内部窗口置顶
        f.setContentPane(desktop);//将桌面面板作为顶层窗口的内容面板
        f.showMe();
    }

    public static void main(String[] args) {
        new JInternalFrameDemo().init();
    }
}
